package com.dgut.legalservice.dao;

import com.dgut.legalservice.domain.Company;
import org.apache.ibatis.annotations.*;

@Mapper
public interface ICompanyDao extends tk.mybatis.mapper.common.Mapper<Company> {

    /**
     * 添加公司核名信息
     * @param company
     * @return
     */
    @Insert("insert into t_company(companyName,backupName1,backupName2,address,amount,amountType,investmentType,limitPeriod" +
            ",harvestAddress) values (#{companyName},#{backupName1},#{backupName2},#{address},#{amount},#{amountType}," +
            "#{investmentType},#{limitPeriod},#{harvestAddress})")
    @SelectKey(keyColumn="id",keyProperty="id",resultType=Integer.class,before =
            false, statement = {"select last_insert_id()"})
    public int addComponyName(Company company);

    /**
     * 添加公司新设信息
     * @param company
     * @return
     */
    @Insert("insert into t_company(demandNum,personId,originalPeriod,newPeriod,amountChangeType,beforeRegAmount,afterRegAmount," +
            "investmentAmount,investmentTime) values (#{demandNum},#{personId},#{originalPeriod},#{newPeriod},#{amountChangeType}," +
            "#{beforeRegAmount},#{afterRegAmount},#{investmentAmount},#{investmentTime})")
    @SelectKey(keyColumn="id",keyProperty="id",resultType=Integer.class,before =
            false, statement = {"select last_insert_id()"})
    public int addComponyCreat(Company company);

    /**
     * 添加公司印章信息
     * @param company
     * @return
     */
    @Insert("insert into t_company(newSeal,sealType,sealMaterial,sealOthers) values (#{newSeal},#{sealType},#{sealMaterial},#{sealOthers})")
    @SelectKey(keyColumn="id",keyProperty="id",resultType=Integer.class,before =
            false, statement = {"select last_insert_id()"})
    public int addComponySeal(Company company);

    /**
     * 添加公司银行开户信息
     * @param company
     * @return
     */
    @Insert("insert into t_company(hasSelect,bankName,bankAddress,largePaymentNum,clearingNum,managerName,contactPhone,contactAddress) values" +
            "(#{hasSelect},#{bankName},#{bankAddress},#{largePaymentNum},#{clearingNum},#{managerName},#{contactPhone},#{contactAddress})")
    @SelectKey(keyColumn="id",keyProperty="id",resultType=Integer.class,before =
            false, statement = {"select last_insert_id()"})
    public int addComponyBank(Company company);

    @Select("select * from t_company where id in (select companyId from t_product_real where orderId = #{id})")
    public Company findCompanyById(Integer id);
}
